<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
    <h:head />
    <h:body>
        <ui:composition template="template.xhtml">
            <ui:define name="title">
                Event Information
            </ui:define>
            <ui:define name="content">
                <!--______________ MAIN CONTENT ______________-->
                
                <h:form id="registrationform">
                    <h:panelGrid columns ="2">
                    <p:panel>
                        <h3>Event Information</h3>
                        
                            <h:panelGrid columns="2" id="regGrid">
                                <h:outputLabel for="name">Name:</h:outputLabel>
                                <p:outputLabel id="name" value="#{viewEventBean.event.name}"/>
                                
                                <h:outputLabel for="organizerName">Organizer Name:</h:outputLabel>
                                <p:outputLabel id="organizerName" value="#{viewEventBean.event.organizer.name}"/>
                                
                                <h:outputLabel for="organizerSurname">Organizer Surname:</h:outputLabel>
                                <p:outputLabel id="organizerSurname" value="#{viewEventBean.event.organizer.surname}"/>
                                
                                <h:outputLabel for="organizerEmail">Organizer Email:</h:outputLabel>
                                <p:outputLabel id="organizerEmail" value="#{viewEventBean.event.organizer.email}"/>
                                
                                <h:outputLabel for="dateStart" value="Date Start:" />
                                <p:outputLabel id="dateStart" value="#{viewEventBean.event.timeStart}"/>
                                
                                <h:outputLabel for="dateEnd" value="Date End:" />
                                <p:outputLabel id="dateEnd" value="#{viewEventBean.event.timeEnd}"/>
                                
                                
                                <h:outputLabel for="predefinedTypology" value="Typology: "  rendered="#{viewEventBean.event.predefinedTypology != 'other'}"/>
                                <p:outputLabel id="predefinedTypology" value="#{viewEventBean.event.predefinedTypology}" rendered="#{viewEventBean.event.predefinedTypology != 'other'}"/>
                                
                                <h:outputLabel for="notPredefinedTypology" value="Typology: " rendered="#{viewEventBean.event.predefinedTypology == 'other'}"/>
                                <p:outputLabel id="notPredefinedTypology" value="#{viewEventBean.event.notPredefinedTypology}" rendered="#{viewEventBean.event.predefinedTypology == 'other'}"/> 
                                
                                <h:outputLabel for="description" value="Description:" />
                                <p:outputLabel id="description" value="#{viewEventBean.event.description}"/> 
                                
                                <h:outputLabel for="town" value ="Place:" />
                                <p:outputLabel id="town" value="#{viewEventBean.event.location}"/>
                                
                                <h:outputLabel for="outdoor" value="Outdoor:"/> 
                                <h:outputLabel id="outdoor" value="#{viewEventBean.event.outdoor}"/>
                                
                                <h:outputLabel for="wind1, wind2, wind3" value="Wind:" rendered="#{viewEventBean.event.acceptedWeatherConditions != null}"/>
                                <p:outputLabel id="wind1" value="Absent" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.wind == 0.0}"/>
                                <p:outputLabel id="wind2" value="Medium (0-8 m/s)" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.wind == 1.0}"/> 
                                <p:outputLabel id="wind3" value="High (more than 8 m/s)" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.wind == 2.0}"/>
                                
                                <h:outputLabel for="precipitation" value="Accepted Precipitation:" rendered="#{viewEventBean.event.acceptedWeatherConditions != null}"/>
                                <p:outputLabel id="precipitation" value="#{viewEventBean.event.acceptedWeatherConditions.precipitation}" rendered="#{viewEventBean.event.acceptedWeatherConditions != null}"/>
                                
                                <h:outputLabel for="temperature1, temperature2, temperature3, temperature4" value="Temperature:" rendered="#{viewEventBean.event.acceptedWeatherConditions != null}"/>
                                <p:outputLabel id="temperature1" value="less than 0 °C" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.temperature == 0.0}"/>
                                <p:outputLabel id="temperature2" value="0-10 °C" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.temperature == 1.0}"/>
                                <p:outputLabel id="temperature3" value="10 - 20 °C" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.temperature == 2.0}"/>
                                <p:outputLabel id="temperature4" value="more than 20°" rendered="#{viewEventBean.event.acceptedWeatherConditions != null and viewEventBean.event.acceptedWeatherConditions.temperature == 3.0}"/>
                            </h:panelGrid>
                    </p:panel>
                            <p:panel>
                                <h3>Weather Forecast</h3>
                                <h:panelGrid columns = "2">
                                    <h:outputLabel for="weatherForecast" value="Weather Forecast:" rendered="#{viewEventBean.event.weatherForecast != null}"/>
                                    <p:graphicImage id="weatherForecast" value="http://openweathermap.org/img/w/#{viewEventBean.event.weatherForecast.icon}.png" rendered="#{viewEventBean.event.weatherForecast != null}"/>
                                    
                                    <h:outputLabel for="tempForecast" value="Temperature Forecast:" rendered="#{viewEventBean.event.weatherForecast != null}"/>
                                    <h:outputLabel id="tempForecast" value="#{viewEventBean.event.weatherForecast.temperatureFormat} °C" rendered="#{viewEventBean.event.weatherForecast != null}"/>
                                    
                                    <br/>
                                    <h:outputLabel id="rainForecasted" value="Expected rain" rendered="#{viewEventBean.event.weatherForecast != null 
                                                                                                         and viewEventBean.event.weatherForecast.precipitation == true}"/>
                                    
                                    <h:outputLabel id="NOrainForecasted" value="NO expected rain" rendered="#{viewEventBean.event.weatherForecast != null 
                                                                                                              and viewEventBean.event.weatherForecast.precipitation == false}"/>
                                    
                                    <h:outputLabel for="windForecast" value="Wind Forecast:" rendered="#{viewEventBean.event.weatherForecast != null}"/>
                                    <h:outputLabel id="windForecast" value="#{viewEventBean.event.weatherForecast.wind} m/s" rendered="#{viewEventBean.event.weatherForecast != null}"/>
                                    
                                </h:panelGrid>
                            </p:panel>
                        </h:panelGrid>
                </h:form>
                <br>
                    
                    
                    
                    
                    
                </br>
                <h:form id="formButton" rendered="#{viewEventBean.event.deleted==false and !viewEventBean.creator}">
                    <p:commandButton id="acceptInvitation" 
                                     value="Accept Invitation" 
                                     actionListener="#{viewEventBean.acceptInvitation()}"
                                     rendered="#{viewEventBean.findInviteStatusInvited==true}"
                                     update="formButton"/>
                    <p:commandButton id="refuseInvitation" 
                                     value="Refuse Invitation" 
                                     actionListener="#{viewEventBean.refuseInvitation()}" 
                                     rendered="#{viewEventBean.findInviteStatusInvited==true}"
                                     update="formButton"/>
                    <p:commandButton id="reAcceptInvitation" 
                                     value="Re-accept Invitation" 
                                     actionListener="#{viewEventBean.acceptInvitation()}"
                                     rendered="#{viewEventBean.findInviteStatusDelayed==true}" 
                                     update="formButton"/>
                    <p:commandButton id="deleteParticipation" 
                                     value="Delete Participation" 
                                     actionListener="#{viewEventBean.deleteParticipation()}"
                                     rendered="#{viewEventBean.findInviteStatusAccepted==true}" 
                                     update="formButton"/>
                    <h:outputLabel value="You have refused to participate to this event" rendered="#{viewEventBean.findInviteStatusNotAccepted==true}" />
                    <p:messages id="messageError" globalOnly="true" showDetail="true" autoUpdate="true" closable="true" />
                </h:form>
                <h:form rendered="#{viewEventBean.event.deleted==true}">
                    <h:outputText value="This event has been deleted by its organizer"/>
                </h:form>
                
                <p:outputLabel rendered="#{viewEventBean.badWeatherConditions and viewEventBean.creator and viewEventBean.suggestedDate != null}" value="Bad Weather condition, the suggestion for a new date start is: #{viewEventBean.suggestedDate}"/>
                <p:outputLabel rendered="#{viewEventBean.badWeatherConditions and viewEventBean.creator and viewEventBean.suggestedDate == null}" value="Bad Weather condition, there's no suggested date for the next days"/>       
                
                <p:commandButton rendered="#{viewEventBean.creator}" action="#{createdEventsBean.showModifyEvent(viewEventBean.event, viewEventBean.event.acceptedWeatherConditions)}" value="Modify event"/>
                
                <h:panelGrid id="pnlAccepted">
                    
                    <p:dataTable rendered="#{viewEventBean.accepted != null and viewEventBean.accepted.size()!=0}"
                                 value="#{viewEventBean.accepted}"
                                 styleClass="order-table"
                                 var="acc"
                                 >
                        <f:facet name="header">
                            Accepted Participation People
                        </f:facet>
                        <p:column headerText="Name">
                            #{acc.name}
                        </p:column>
                        <p:column headerText="Surname">
                            #{acc.surname}
                        </p:column>
                        <p:column headerText="Email">
                            #{acc.email}
                        </p:column>
                        <p:column>
                            <h:form>
                                <p:commandButton value="View Profile" action="#{viewEventBean.viewProfile(acc)}"/>
                            </h:form>
                        </p:column>
                    </p:dataTable>
                </h:panelGrid>
                
                <h:panelGrid id="pnlInvitations" rendered="#{viewEventBean.creator}">
                    <p:dataTable rendered="#{viewEventBean.refused != null and viewEventBean.refused.size()!=0 }"
                                 value="#{viewEventBean.refused}"
                                 styleClass="order-table"
                                 var="acc">
                        <f:facet name="header">
                            Refused Participation People
                        </f:facet>
                        <p:column headerText="Name">
                            #{acc.name}
                        </p:column>
                        <p:column headerText="Surname">
                            #{acc.surname}
                        </p:column>
                        <p:column headerText="Email">
                            #{acc.email}
                        </p:column>
                        <p:column>
                            <h:form>
                                <p:commandButton value="View Profile" action="#{viewEventBean.viewProfile(acc)}"/>
                            </h:form>
                        </p:column>
                    </p:dataTable>
                    
                    <p:dataTable rendered="#{viewEventBean.pendent != null and viewEventBean.pendent.size()!=0}"
                                 value="#{viewEventBean.pendent}"
                                 styleClass="order-table"
                                 var="acc">
                        <f:facet name="header">
                            Pendent Participation People
                        </f:facet>
                        <p:column headerText="Name">
                            #{acc.name}
                        </p:column>
                        <p:column headerText="Surname">
                            #{acc.surname}
                        </p:column>
                        <p:column headerText="Email">
                            #{acc.email}
                        </p:column>
                        <p:column>
                            <h:form>
                                <p:commandButton value="View Profile" action="#{viewEventBean.viewProfile(acc)}"/>
                            </h:form>
                        </p:column>
                    </p:dataTable>
                </h:panelGrid>
            </ui:define>
            
        </ui:composition>
    </h:body>
</html>
